package com.eling.elcms.integration.uradio.event;

import com.eling.elcms.member.service.IMemberManager;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

/**
 * 逸和园优频定位临时解决方案：自启动单线程调度，存储逸和园会员的定位数据。
 * @author ZhangPeng
 */
@Service
@Lazy(false)
public class YHYUradioMemberLocation implements InitializingBean {
//	private static final Log log = LogFactory.getLog(YHYUradioMemberLocation.class);
	
	@Autowired
	private IMemberManager memberManager;
	@Autowired
	private UradioMemberLocationListener uadioMemberLocationListener;
	
//	@SuppressWarnings("unused")
	@Override
	public void afterPropertiesSet() throws Exception {

//		Runnable runnable = new Runnable() {
//			public void run() {
//				// 提交数据
//				try {
//					//硬编码，查询逸和园机构下的所有会员。
//					Member memberCon = new Member();
//					PropertyUtils.setProperty(memberCon,"organization.pkOrganization",608);
//					List<Member> memberList = memberManager.query(memberCon);
//					if(CollectionUtils.isEmpty(memberList)) {
//						return;
//					}
//					//会员定位，保存数据。
//					for(Member member : memberList) {
//						GetMemLocFromDvcEvent event = new GetMemLocFromDvcEvent(member);
//						uadioMemberLocationListener.doEvent(event);
//					}
//				} catch (Exception e) {
//					log.error("逸和园记录定位出现异常",e);
//				}
//			}
//		};
		//启动后延迟10秒开始自动运行，每次执行完毕后间隔3分钟开始下一次执行。
//		Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(
//				runnable, 10, 3*60, TimeUnit.SECONDS);
		
	}
	
	
	

}
